<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/14
 * Time: 16:10
 */

namespace app\common\entity;


use think\Model;

class MachineList extends Model
{
    protected $table = 'machine_list';

    public function addList($uid, $level, $types)
    {

        $entity = new self();
        $entity->user_id = $uid;
        $entity->level = $level;
        $entity->status = 1;
        $entity->create_time = time();
        $entity->get_time = time();
        $entity->types = $types;
        $result = $entity->save();
        if ($result) {
            return true;
        }
        return false;
    }

    public function insMachine($uid, $level,$types ,$num)
    {
        // $hasMachine = new HasMachine();
        if ($num <= 0) {
            return true;
        }
        for ($i = 0 ; $i < $num ; $i++){
            $this->addList($uid,$level,$types);
            // $hasMachine->updMachineNum($uid,$level);
        }
        return true;
    }
}